package com.ruoyi.business.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.business.MyPage;
import com.ruoyi.business.PageConfig;
import com.ruoyi.business.mapper.UserBuyVipMapper;
import com.ruoyi.business.vo.UserBuyVipListVO;
import com.ruoyi.common.common.ResultBody;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;


/**
 * @title: StatisticsService
 * @copyright: copyright (c) 2021
 * @author: jiangguanjun
 * @date: 2023/2/9 16:22
 * @firstReview:
 * @lastReview:
 * @desc:  统计相关
 */
@Slf4j
@Component
public class UserBuyVipService {

    @Autowired
    private UserBuyVipMapper userBuyVipMapper ;


    public ResultBody vipBuyList(Long startTime, Long endTime) {
        MyPage myPage = PageConfig.getPage() ;
        Page<UserBuyVipListVO> page = new Page<>(myPage.getPageNum(), myPage.getPageSize());
        Date startDate = null ;
        Date endDate = null;
        if(startTime != null){
            startDate =new Date(startTime) ;
        }

        if(endTime != null){
            endDate = new Date(endTime) ;
        }

        IPage<UserBuyVipListVO> iPage = userBuyVipMapper.queryPage(page,startDate,endDate);

        return ResultBody.success(iPage) ;

    }
}
